﻿<?php
include_once("globals.php");

class mysqllib {
	private $db;
	
	public function __construct($value = false) {
		if (!$this -> db = mysql_connect('localhost', $GLOBALS['mysqlUser'], $GLOBALS['mysqlPassword'], $GLOBALS['mysqlDb'])) {
			die('Not Connected' . mysql_error());
			
			echo 'The connection to the database failed. Please try again. If this keeps happening, please contact the webmaster.';
		}
		if (!mysql_select_db($GLOBALS['mysqlDb'], $this -> db)) {
			die('Can\'t use cs597' . mysql_error());
			echo 'Error during the selection of the database.';
		}
		mysql_query("SET NAMES utf8");
		mysql_query("SET CHARACTER SET utf8");
	}

	public function __destruct() {
		if (!mysql_close($this -> db)) {
			
			echo 'Error during the closure of the database.';
			die('Still Connected' . mysql_error());
		}
	}

}
?>